<?php

namespace app\admin\validate;
use think\Validate;

class CompanyValidate extends Validate
{
    protected $rule = [
            'group_id'      => 'require',
            'name'          => 'require|max:100|unique:company,name,group_id^delete_time',
            'contact'       => 'require|max:100',
            'phone'         => 'require|max:20|unique:company,phone,group_id^delete_time',
            'user.username' => 'require|max:100|unique:company_user,username,company_id^delete_time',
            'user.phone'    => 'require|max:20|unique:company_user,phone,company_id^delete_time',
    ];

    protected $message = [
            'group_id.require'      => '请选择分组',
            'name.require'          => '请输入公司名称',
            'name.max'              => '公司名称不能超过100个字符',
            'name.unique'           => '公司名称已存在',
            'contact.require'       => '请输入联系人',
            'contact.max'           => '联系人不能超过100个字符',
            'phone.require'         => '请输入联系电话',
            'phone.max'             => '联系电话不能超过20个字符',
            'phone.unique'          => '联系电话已存在',
            'user.username.require' => '请输入用户名',
            'user.username.max'     => '用户名不能超过100个字符',
            'user.username.unique'  => '用户名已存在',
            'user.phone.require'    => '请输入手机号',
            'user.phone.max'        => '手机号不能超过20个字符',
            'user.phone.unique'     => '手机号已存在',
    ];

    protected $scene = [
            'add' => ['group_id', 'name', 'contact', 'phone', 'user.username', 'user.phone'],
    ];
}